package top.kaoshanji.p1ch08b;

/**
 * 代码清单-p1ch08b-190页a：初始化的全过程
 * author kaoshanji
 * ^_^
 * create time 2025/3/9 17:13
 */
public class Beetle extends Insect {

    private int k = printInit("Beetle.k initialized");

    public Beetle() {
        System.out.println("k = " + k);
        System.out.println("j = " + j);
    }

    private static int x2 = printInit("static Beetle.x2 initialized");

    public static void main(String[] args) {
        // 1.1、父类静态属性
        // 1.2、自身静态属性
        // 2、main方法里
        System.out.println("Beetle constructor");
        // 3、基类构造器
        // 4、实例属性
        // 5、自身构造器
        new Beetle();
    }


}

class Insect {

    // 定义时声明值
    private int i = 9;
    protected int j;

    // 构造器初始化
    Insect() {
        System.out.println("i = " + i + ", j = " + j);
        j = 39;
    }

    // 调用方法初始化
    private static int x1 = printInit("static Insect.x1 initialized");

    static int printInit(String s) {
        System.out.println(s);
        return 47;
    }


}


